package com.nine.gxh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nine.gxh.mapper.GxhMessageMapper;
import com.nine.gxh.model.GxhMessage;
import com.nine.gxh.service.GxhMessageService;
import com.nine.gxh.vos.GxhMessageVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author: duonine
 * @date: 2023/7/19
 */
@Service
public class GxhMessageServiceImpl extends ServiceImpl<GxhMessageMapper, GxhMessage> implements GxhMessageService {

    @Override
    public IPage<GxhMessage> listPage(IPage<GxhMessage> page, GxhMessageVo vo) {
        LambdaQueryWrapper<GxhMessage> wrapper = Wrappers.lambdaQuery();
        // 查询未读状态数据
        wrapper.eq(GxhMessage::getMstate, "1");
        wrapper.like(StringUtils.hasText(vo.getTitle()), GxhMessage::getTitle, vo.getTitle());
        return this.baseMapper.selectPage(page, wrapper);
    }
}
